package io.renren.modules.reception.init;

import cn.hutool.core.util.ObjectUtil;
import io.renren.modules.store.entity.TTableThemeEntity;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 功能说明： 餐台主题缓存
 * <p>
 * Original @Author: steakliu-刘牌, 2022-12-03  21:41
 * <p>
 * Copyright (C)2020-2022  steakliu All rights reserved.
 */
public class TableThemeCache {

    private static final Map<Long, TTableThemeEntity> tableThemeEntityCache = new ConcurrentHashMap<>();

    public static void put(final Long sellerId , final TTableThemeEntity entity){
        tableThemeEntityCache.put(sellerId, entity);
    }

    public static TTableThemeEntity get(final Long sellerId){
        TTableThemeEntity theme = tableThemeEntityCache.get(sellerId);
        if (ObjectUtil.isNull(theme)){
            theme = tableThemeEntityCache.get(1L);
            if (ObjectUtil.isNull(theme)){
                theme =  ColorFactory.get();
            }
        }
        return theme;
    }
}
